﻿@using Apps.Web.Core;
@using Apps.Common;
@using Apps.Models.PUB;
@using Apps.Web;
@using Apps.Locale;
@using Apps.Models.Sys;
@using Apps.Models.Enum;
@using Apps.Models.HuaChan;
@model List<HUACHAN_PROJECT_FIELDS>
@{
    ViewBag.Title = "创建";
    Layout = "~/Views/Shared/_Index_LayoutEdit.cshtml";
    List<permModel> perm = null;
}

<script type="text/javascript">
    $(function () {
        $("#btnSave").click(function () {
            if ($("form").valid()) {
                $.ajax({
                    url: "@Url.Action("Edit")",
                    type: "Post",
                    data: $("form").serialize(),
                    dataType: "json",
                    success: function (data) {
                        if (data.type == 1) {
                            window.parent.frameReturnByMes(data.message);
                            window.parent.frameReturnByReload(true);
                            window.parent.frameReturnByClose()
                        }
                        else {
                            window.parent.frameReturnByMes(data.message);
                        }
                    }
                });
            }
            return false;
        });
        $("#btnReturn").click(function () {
            window.parent.frameReturnByClose();
        });
    });
</script>
<div class="mvctool bgb">
    @Html.ToolButton("btnSave", "fa fa-save", Resource.Save, ref perm, "Save", true)
    @Html.ToolButton("btnReturn", "fa fa-reply", Resource.Reply, false)
</div>
@using (Html.BeginForm())
{
    <input class="text-box single-line" style="display:none;" id="projectId" name="projectId" type="text" value="@ViewBag.projectId" autocomplete="off">
    <input class="text-box single-line" style="display:none;" id="ID" name="ID" type="text" value="@ViewBag.dataId" autocomplete="off">
   
<table class="formtable">
    <tbody>
        @foreach (var item in Model)
        {
            <tr>
                <th>
                    <label for="@item.FIELDNAME">
                        @if (item.REQUIRED == "是")
                        {
                            <font color="red">*</font>
                        }
                        @item.FIELDNAME
                    </label>：
                </th>
                <td>

                    @if (item.REQUIRED == "是")//必填
                    {
                        if (item.FIELDTYPE == "文本")//单行文本
                        {
                            <input class="text-box single-line" data-val="true" data-val-required="字段是必需的。" id="DATA@(item.COLUMNIDX)" name="DATA@(item.COLUMNIDX)" type="text" value="@(item.vaule)" autocomplete="off">
                        }
                        else if (@item.FIELDTYPE == "时间")//时间
                        {
                            <input id="DATA@(item.COLUMNIDX)" data-val-required="字段是必需的。" name="DATA@(item.COLUMNIDX)" onfocus="WdatePicker({ dateFmt: 'yyyy-MM-dd HH:mm:ss' })" type="text" class="searchText" value="@(item.vaule)" data-options="required:true" />

                        }
                        else
                        {
                            <input class="easyui-numberbox" data-val="true" data-val-required="字段是必需的。" validType:'email' precision="@(item.KEEPPOINT)" min="0" id="DATA@(item.COLUMNIDX)" name="DATA@(item.COLUMNIDX)" type="text" value="@(item.vaule)" autocomplete="off">
                            if (Utils.ObjToDecimal(item.MAX, 0) > 0)
                            {
                                <font color="red">(@Utils.ObjToDecimal(item.MIN, 0)-@Utils.ObjToDecimal(item.MIN, 0))</font>
                            }
                        }
                    }
                    else
                    {
                        if (item.FIELDTYPE == "文本")//单行文本
                        {
                            <input class="text-box single-line" id="DATA@(item.COLUMNIDX)" name="DATA@(item.COLUMNIDX)" type="text" value="@(item.vaule)" autocomplete="off">
                        }
                        else if (@item.FIELDTYPE == "时间")//时间
                        {
                            <input id="DATA@(item.COLUMNIDX)" name="DATA@(item.COLUMNIDX)" onfocus="WdatePicker({ dateFmt: 'yyyy-MM-dd HH:mm:ss' })" type="text" class="searchText" data-options="required:true" value="@(item.vaule)" />

                        }
                        else
                        {
                            <input class="easyui-numberbox" precision="@(item.KEEPPOINT)" min="0" id="DATA@(item.COLUMNIDX)" name="DATA@(item.COLUMNIDX)" type="text" value="@(item.vaule)" autocomplete="off">
                            if (Utils.ObjToDecimal(item.MAX, 0) > 0)
                            {
                                <font color="red">(@Utils.ObjToDecimal(item.MIN, 0)-@Utils.ObjToDecimal(item.MAX, 0))</font>
                            }
                        }
                    }
                </td>
            </tr>
        }
    </tbody>
</table>
@Html.ValidationSummary()
}

